#coding=utf-8
"""
Author:陆孝
Time:2025/9/4 0004 15:32
"""

'''
此模块是用来生成测试报告以及发送邮件的模块
'''
import time
import unittest
from library.HTMLTestRunnerNew import HTMLTestRunner
from library.mail import SendMail
from utils.handle_path import *

now = time.strftime("%Y-%m-%d-%H-%M-%S")
filename = report_path + "\\" + str(now) + "api_cms_report.html"

def auto_run():
    discover = unittest.defaultTestLoader.discover(start_dir=testcase_path,
                                                   pattern="test_*.py")
    f = open(filename,'wb')
    runner = HTMLTestRunner(stream=f,
                            title="cms平台接口自动化测试报告",
                            description="测试用例执行情况如下",
                            tester="小陆")
    runner.run(discover)
    f.close()
def sendMail():
    sm = SendMail(send_msg=filename,attachment=filename)
    sm.send_mail()

if __name__ == '__main__':
    auto_run()
    sendMail()